<template>
  <div class="comp-monitor-device-group-obox">
    <div class="comp-monitor-device-group">
      <div class="comp-monitor-device-group-header">
        <div class="comp-monitor-device-group-header-title">
          <img src="@/assets/cloudV2/img/title.png" alt="">
          <span class="content">设备列表</span>
        </div>
      </div>
      <div class="comp-monitor-device-group-box topItem">
        <li class='flexBox'>
          <div class="comp-monitor-device-group-box-item">
            <span class="itemInfo">设备名称</span>
          </div>
          <div>
            稼动率
          </div>
        </li>
      </div>
      <Scrollbar>
        <div class="comp-monitor-device-group-box">
          <ul style="padding: 0">
            <li class="flexBox" v-for="i in devs" @click="$emit('showTip',i)">
              <div  class="comp-monitor-device-group-box-item">
                <el-tag size="large"
                        style="background-color: hsla(220,4%,58%,.1);border-color: hsla(220,4%,58%,.2);"
                        effect="light"
                        :type="getDevType(i)">
                  {{getDevStatus(i)}}
                </el-tag>
                <span class="itemInfo">{{ i.name }}</span>
              </div>
              <div>
                {{(i.utilization*100).toFixed(2) + '%'}}
              </div>
            </li>
          </ul>
        </div>
      </Scrollbar>
      <img class="left-top" src="@/assets/cloudV2/img/top-left.png" alt="">
      <img class="right-top" src="@/assets/cloudV2/img/top-left.png" alt="">
      <img class="right-bottom" src="@/assets/cloudV2/img/top-left.png" alt="">
      <img class="left-bottom" src="@/assets/cloudV2/img/top-left.png" alt="">
    </div>
  </div>
</template>

<script setup>
import Scrollbar from '@/components/ScrollBar/index.vue'
import CompTip from "./CompTip.vue";

const props = defineProps({
  devs: Array,
})

function getDevStatus(item){
  if(item.data?.substring(2,3)  == '1') return '报警'
  if(item.data?.substring(3) == '1') return '运行'
  if(item.data?.substring(1,2) == '1' || item.data == '0000') return '待机'
  if(item.data?.substring(0,1) == '1') return '关机'
  return '关机'
}
function getDevType(item){
  if(item.data?.substring(2,3)  == '1') return 'danger'
  if(item.data?.substring(3) == '1') return 'success'
  if(item.data?.substring(1,2) == '1' || item.data == '0000') return 'warning'
  if(item.data?.substring(0,1) == '1') return 'info'
  return 'info'
}
</script>

<style scoped>
.comp-monitor-device-group-header {
  width: 100%;
  position: absolute;
  top: 0;
  left: 0;
  padding: 12px 12px 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.comp-monitor-device-group {
  padding: 0 12px;
  font-size: 14px;
  position: relative;
  width: 100%;
  height: 100%;
  background: url("@/assets/cloudV2/img/monitor-box-slide-group-new.png") no-repeat 0 0;
  background-size: 100% 100%;
  padding-top: 42px;
  box-sizing: border-box;
  overflow: hidden;
}
.comp-monitor-device-group-header-title {
  width: 80px;
  margin-right: 8px;
}
.comp-monitor-device-group-header-title, .comp-monitor-device-group-header-search {
  display: flex;
  align-items: center;
}
.comp-monitor-device-group-header span {
  display: inline-block;
  margin-left: 8px;
  color: #ffffff;
}
.comp-monitor-device-group-box {
  height: calc(100% - 30px) !important;
}
.comp-monitor-device-group-box ul li{
  color: #fff;
}
.left-top {
  position: absolute;
  width: 5%;
  top: 0;
  left: 0;
}

.right-top {
  position: absolute;
  width: 5%;
  top: 0;
  right: 0;
  transform: rotate(90deg)
}

.right-bottom {
  position: absolute;
  width: 5%;
  bottom: 0;
  right: 0;
  transform: rotate(180deg)
}

.left-bottom {
  position: absolute;
  width: 5%;
  bottom: 0;
  left: 0;
  transform: rotate(-90deg)
}
.easy-scrollbar {
  height: calc(100% - 30px) !important;
  margin-top: 0px !important;
}
.noMarging .easy-scrollbar__wrap{
  margin-right: 0px !important;
}
.topItem {
  height: 30px !important;
  padding: 0;
}
.flexBox {
  padding-right: 22px !important;
  color: #32EBCA;
  list-style: none;
  font-size: 15px;
  display: flex;
  justify-content: space-between;
  margin: 10px;
  cursor: pointer;
}
.comp-monitor-device-group-box-item {
  padding-right: 8px;
  display: flex;
  align-items: center;
}
.comp-monitor-device-group-box-item .itemInfo {
  white-space: normal;
  word-break: break-all;
  margin-left: 4px;
}
</style>